package com.karl.loading.base;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;

import com.karl.loading.base.BaseView;

/**
 * Created by Karl on 2017/8/25 0025.
 * desc:
 */

public abstract class BaseProgressView extends BaseView {

    protected final int MODE_PROGRESS = 100;

    protected final int MODE_LOADING = 200;

    protected int mMaxProgress = 0;

    protected int mCurrentMode;

    public BaseProgressView(Context context) {
        this(context,null);
    }

    public BaseProgressView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void startAnim(int repeatCount, int repeatMode, long time) {
        stopAnim();
        setMode(MODE_LOADING);
        super.startAnim(repeatCount, repeatMode, time);
    }

    public int getMaxProgress() {
        return mMaxProgress;
    }


    public int getCurrentMode() {
        return mCurrentMode;
    }

    /**
     * 模式设置
     * @param currentMode mode
     */
    protected void setMode(int currentMode){
        this.mCurrentMode = currentMode;
    }

    protected void setMaxProgress(int maxProgress){
        this.mMaxProgress = maxProgress;
    }


    /**
     * 更新进度
     */
    public void updateProgress(int progress){
        setMode(MODE_PROGRESS);

    }

    public void updateProgress(float progress){
        setMode(MODE_PROGRESS);
    }

}
